
//
//  HUD.m
//  摇一摇
//
//  Created by 零零壹 on 2017/1/16.
//  Copyright © 2017年 零零壹. All rights reserved.
//

#import "HUD.h"

@implementation HUD

-(instancetype)init
{
    if (self = [super init]) {
        
    }
    return self;
}

// 开始加载动画
-(void)starProgresshud
{
    UIWindow *window = [[UIApplication sharedApplication].windows firstObject];
    self.hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
}






// 结束加载
-(void)stopProgresshud
{
    if (self.hud) {
         [self.hud hideAnimated:YES];
    }else
    {

    }
}

-(void)starProgresshudBlueHud:(NSString *)hudtext
{
    UIWindow *window = [[UIApplication sharedApplication].windows firstObject];
    self.hud.mode = MBProgressHUDModeText;
    self.hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
    self.hud.label.text = hudtext;
    self.hud.bezelView.backgroundColor = [UIColor blackColor];
    self.hud.label.textColor = [UIColor whiteColor];
}
-(void)stopProgresshudBlueHud
{
    if (self.hud) {
        [self.hud hideAnimated:YES];
    }else
    {
        
    }
}


// 创建hud
+(MBProgressHUD *)createHud
{
    UIWindow *window = [[UIApplication sharedApplication].windows firstObject];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
    return hud;
}


// 加载动画
+(void)ShowDoProgressAfterTime:(NSTimeInterval)time
{
    MBProgressHUD *hud = [self createHud];
    [hud hideAnimated:YES afterDelay:time];
}


// 默认文本样式
+(void)showNomorText:(NSString *)text AfterTime:(NSTimeInterval)time;
{

    MBProgressHUD *hud = [self createHud];
    hud.mode = MBProgressHUDModeText;
    hud.label.text = text;
    [hud hideAnimated:YES afterDelay:time];
}


// 黑色文本样文本样式
+(void)showText:(NSString *)text AfterTime:(NSTimeInterval)time
{
    if (text.length == 0)
    {
        
    }else
    {
        MBProgressHUD *hud = [self createHud];
        hud.mode = MBProgressHUDModeText;
        hud.label.text = text;
        hud.bezelView.backgroundColor = [UIColor blackColor];
        hud.label.textColor = [UIColor whiteColor];
        [hud hideAnimated:YES afterDelay:time];
    }
    

}


+(void)starHudShowBlueApi
{
    MBProgressHUD *hud = [self createHud];
    hud.mode = MBProgressHUDModeText;
    hud.label.text = @"";
    hud.bezelView.backgroundColor = [UIColor blackColor];
    hud.label.textColor = [UIColor whiteColor];
    [hud hideAnimated:YES afterDelay:3];
}

-(void)starProgresshudBlueApi
{
    
}

// 圆环
+(void)showRotundityAfterTime:(NSTimeInterval)time
{
    MBProgressHUD *hud = [self createHud];
    hud.mode = MBProgressHUDModeDeterminate;
    [hud hideAnimated:YES afterDelay:time];
}




// 错误信息提示弹框
+(void)showError:(NSString *)text AfterTime:(NSTimeInterval)time errorimage:(UIImage *)image;
{
    MBProgressHUD *hud = [self createHud];
    hud.mode = MBProgressHUDModeCustomView;
   UIImageView *imageV=[[UIImageView alloc]initWithImage:image];
    hud.customView = imageV;
    hud.square = YES;
    hud.label.text=[NSString stringWithFormat:@"%@",text];
    [hud hideAnimated:YES afterDelay:time];
}
// 正确信息提示
+(void)showSuccess:(NSString *)text AfterTime:(NSTimeInterval)time successimage:(UIImage *)image;
{
    MBProgressHUD *hud = [self createHud];
    hud.mode = MBProgressHUDModeCustomView;
    hud.customView=[[UIImageView alloc]initWithImage:image];
    hud.label.text=[NSString stringWithFormat:@"%@",text];
    [hud hideAnimated:YES afterDelay:time];
}





@end
